#!/bin/sh
if [ -z "$(uci -q get qos.omrvpn)" ]; then
	uci -q batch <<-EOF >/dev/null
		delete qos.wan
		set qos.wan1=interface
		set qos.wan1.classgroup="Default"
		set qos.wan1.enabled="0"
		set qos.wan1.upload="4000"
		set qos.wan1.download="100000"
		set qos.wan2=interface
		set qos.wan2.classgroup="Default"
		set qos.wan2.enabled="0"
		set qos.wan2.upload="4000"
		set qos.wan2.download="100000"
		set qos.omrvpn=interface
		set qos.omrvpn.classgroup="Default"
		set qos.omrvpn.enabled="0"
		set qos.omrvpn.interface="tun0"
		set qos.omrvpn.upload="0"
		set qos.omrvpn.download="0"
		set qos.omrvpn.qdisc="cake"
		set qos.omrvpn.script="layer_cake.qos"
		delete qos.@classify[-1]
		add qos classify
		set qos.@classify[-1].target='Express'
		set qos.@classify[-1].ports='5600'
		set qos.@classify[-1].comments='SIP'
		add qos classify
		set qos.@classify[-1].target='Express'
		set qos.@classify[-1].portrange='27000-27050'
		set qos.@classify[-1].proto='udp'
		set qos.@classify[-1].comments='Steam'
		commit qos
	EOF
	if [ "$(uci -q get network.wan3)" != "" ]; then
		uci -q batch <<-EOF >/dev/null
			set qos.wan3=interface
			set qos.wan3.classgroup="Default"
			set qos.wan3.enabled="0"
			set qos.wan3.upload="4000"
			set qos.wan3.download="100000"
			commit qos
		EOF
	fi
	if [ "$(uci -q get network.wan4)" != "" ]; then
		uci -q batch <<-EOF >/dev/null
			set qos.wan4=interface
			set qos.wan4.classgroup="Default"
			set qos.wan4.enabled="0"
			set qos.wan4.upload="4000"
			set qos.wan4.download="100000"
			commit qos
		EOF
	fi
fi
rm -f /tmp/luci-indexcache

exit 0
